import { MultiPlatform } from '../Model/Platform/MultiPlatform';
import { CallBackHandler } from '../Model/PoolObj/CallBackHandler';
/* eslint-disable */

export enum RequestUrl {
  api_url = 'https://xiaowugui.cygame666.cn:3002',
  /** 登录 */
  LOGIN = '/login',
  /** 获取平台经典模式排行榜 */
  LEADERBOARD = '/leaderboard',
  /** 上传平台经典模式分数 */
  LEADERBOARD_ADD = '/leaderboard/add',
  /** 自己平台经典模式排名 */
  LEADERBOARD_PLAYER = '/leaderboard/player',
  /** 获取平台模式排行榜分页 */
  LEADERBOARD_PAGE = '/leaderboard/page',
  /** 创建用户云存档 */
  USERS_CREATE = '/users/create',
  /** 获取用户云存档数据 */
  USERS_USER = '/users/user',
  /** 更新用户云存档数据 */
  USERS_UPDATE = '/users/update',
  /** 更新用户云存档数据 */
  USERS_UPDATEINFOCACHE = '/users/updateinfocache',
  /** 获得邮件内容*/
  MAIL = '/mail',
  /** 获得邮箱列表 */
  MAIL_MAILBOX = '/mail/mailbox',
  /**删除邮件 */
  MAIL_DELMAIL = '/mail/delmail',
  /** 已读邮件 */
  MAIL_READMAIL = '/mail/readmail',
  /** 领取邮件奖励 */
  MAIL_GETMAILREWARD = '/mail/getmailreward',
  /** 获取平台赛季模式排行榜分页 */
  LEADERBOARD_PLAYERPANGE = '/leaderboard/seasonplayerrange',

  TT_GET_OPENID = '/platform_go_bytedance/get/openId',
}

export class WebRequestHttp {
  static requestGet(url: string, data: any, callback: (...args: any[]) => void, target?: any, ...params: any[]): void {
    const callbackFunc = CallBackHandler.pop(callback, target, params);
    const platform = MultiPlatform.Ins().platformUnit;
    platform.requestHttpGet(url, data, callbackFunc);
  }

  static requestPost(url: string, data: any, callback: (...args: any[]) => void, target?: any, ...params: any[]): void {
    const callbackFunc = CallBackHandler.pop(callback, target, params);
    const platform = MultiPlatform.Ins().platformUnit;
    platform.requestHttpPost(url, data, callbackFunc, {
      'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
      'Content-Type': 'application/json',
    });
  }
}
